#pragma once

#include <vector>
// __START_REPEATED__
#include "__INTERFACE_FILE__.h"
// __END_REPEATED__

namespace google { namespace protobuf { class Message; }}
class MsgDTO;
class ComServer;
class ComClient;

namespace si
{

class StandardInterface
{
public:
	virtual uint16_t category() const = 0;
};

template<typename Ty>
class Register
{
public:
	void regist(Ty *value)
	{
		m_interfaces.push_back(value);
	}
protected:
	std::vector<Ty*> m_interfaces;
};

class StandardInterfaceServer
	: public StandardInterface
// __START_REPEATED__
	, public ::__INTERFACE__
// __END_REPEATED__
{
protected:
	ComServer *m_pComServer = nullptr;

protected:
	bool notify(google::protobuf::Message &msg, int id);

public:
// __START_REPEATED__
	bool notify(const __INTERFACE__::__BROADCAST__ &value);
// __END_REPEATED__
};

class StandardInterfaceClient
	: public StandardInterface
// __START_REPEATED__
	, public Register<::__INTERFACE__>
// __END_REPEATED__
{
protected:
	ComClient *m_pClient = nullptr;

protected:
	template<typename Ty>
	std::vector<Ty*> get_registered_interface()
	{
		return Register<Ty>::m_interfaces;
	}

	template<typename Ty>
	bool notify(const google::protobuf::Message &msg)
	{
		Ty value;
		return notify(msg, value);
	}

// __START_REPEATED__
	bool notify(const google::protobuf::Message &msg,
		__INTERFACE__::__BROADCAST__ &value);
// __END_REPEATED__
public:
	bool dispatch(const MsgDTO &dto);
};

} // namespace si

